<#include "../base.ftl"/>
<#macro cssfile>
</#macro>

<#macro scriptfile>
</#macro>

<#macro breadcrumb>
    <ul class="breadcrumb">
     <#include "../crumb.ftl"/>
     <li class="active">船舶航次</li>
    </ul>
</#macro>


<#macro title>
广大物流云平台
</#macro>

<#macro jsscript>
jQuery(document).ready(function(){
    jQuery("#gridTable").jqGrid({
        url: '${request.contextPath}/list!list.action',
        datatype:"json",
        mtype:'POST',
        height: 270,
        autowidth: true,
        colNames: [
                    '账单编号',
                    '账单代码',
                    '船舶编号',
                    '账单说明',
                    '受理日期',
                    '预计金额',
                    '实际金额',
                    '币种',
                    '最新说明',
                    '状态'
                    ],
        colModel:[
        {
                name : 'billId',
                jsonmap : 'BILL_ID',
                index : 'BILL_ID',
                hidden:false, 
                editable : false,
                searchoptions : {sopt : [ "eq", "cn"]}
        },{
                name : 'billCode',
                jsonmap : 'BILL_CODE',
                index : 'BILL_CODE',
                //editable : true,
                editrules:{required:true}    
        },{
                name : 'shippingId',
                jsonmap : 'SHIPPING_ID',
                index : 'SHIPPING_ID',
                //editable : true,
                editrules:{required:true}    
        },{
                name : 'billTitle',
                jsonmap : 'BILL_TITLE',
                index : 'BILL_TITLE',
                //editable : true,
                //edittype: "select",
                //editoptions:{value:"0:集装箱船;1:滚装船;2:载驳船"},
                editrules:{required:true}     
        },{
                name : 'acceptDate',
                jsonmap : 'ACCEPT_DATE',
                index : 'ACCEPT_DATE',
                //editable : true,
                formatter : 'date',                
                formatoptions : {srcformat : 'Y/m/d',newformat : 'Y-m-d'},
                editoptions :  {dataInit: function(element) {
                     $(element).datepicker({changeMonth : true,changeYear : true,dateFormat : 'yy-mm-dd'});
                }}  
        },{
                name : 'estimatedAmount',
                jsonmap : 'ESTIMATED_AMOUNT',
                index : 'ESTIMATED_AMOUNT',
                //editable : true,
                editrules:{required:true}    
        },{
                name : 'actualAmount',
                jsonmap : 'ACTUAL_AMOUNT',
                index : 'ACTUAL_AMOUNT',
                //editable: true,
                editrules:{required:true}
        },{
                name : 'currency',
                jsonmap : 'CURRENCY',
                index : 'CURRENCY',
                editable : true,
                editrules:{required:true}    
        },{
                name: 'dealNote', 
                jsonmap: 'DEAL_NOTE', 
                index:'DEAL_NOTE', 
                //editable: true,
                searchoptions : {sopt : [ "eq", "cn"]}
        },{
                name: 'status', 
                jsonmap: 'STATUS', 
                index:'STATUS', 
                editable: false,
                hidden:true,
                searchoptions : {sopt : [ "eq", "cn"]}
        }],
            sortname: 'BILL_ID',
            sortorder: 'desc',
            viewrecords: true,
            gridview: true,
            rownumbers : true,
            rowNum: 20,
            rowList: [10,20,30],
            pager : "#gridPager",
            jsonReader : {
                //固化定义
                page : "page.pageNo",
                total : "page.totalPages",
                records : "page.totalCount",
                root : "page.result",
                repeatitems : false,
                //设置主Key
                id : 'BILL_ID'
                },
            prmNames:{
                    rows:"page.pageSize",
                    page:"page.pageNo",
                    sort:"page.orderBy",
                    order:"page.order"},
            pager: "#gridPager",
            loadBeforeSend : function(xhr,settings) {
                //设定访问的list标签
                settings.data = settings.data + "&gridKey=/list#TsmBill";
                return true;
            },
            pager : "#gridPager",
            caption : "账单跟踪"
            }).navGrid('#gridPager', {
             edit: false,
             add: false,
             del: false,
             search: true
        }, {
            //edit
            //beforeShowForm: function(form) {},
            //reloadAfterSubmit : true,
            //closeAfterEdit : true, //修改完毕后关闭
            //afterComplete : opertaionPrompt,
            //设定beanName
            //onclickSubmit :setBeanName
        }, {
            //add
            //beforeShowForm: function(form) {},
            //reloadAfterSubmit : true,
            //closeAfterAdd : true, //新增完毕后关闭
            //afterComplete : opertaionPrompt,
            //设定beanName
            //onclickSubmit :setBeanName,
            //提交前进行验证
            //beforeSubmit :validateSumbit 
        }, {
            //del
            //设定beanName
            //onclickSubmit :setBeanName,
            //reloadAfterSubmit : true,
            //afterComplete : opertaionPrompt
        }).navButtonAdd('#gridPager',{
            caption:"查看详细信息",
            buttonicon:'ui-icon-add',
            onClickButton: function(){
                var selectId=$("#gridTable").jqGrid("getGridParam","selrow");
//                alert(selectId);
                if(selectId==null){
                    alert("您还未选择要查看的信息");
                } else {
                    var consoleDlg=$("#gridDialog");
                    consoleDlg.dialog("option","title","详细信息").dialog("open");
                }
            }
        });

    $("#gridDialog").dialog({
        autoOpen: false,
        model:true,
        resizable:true,
        width: 700,
        height: 350,
        open : function(){
            $("#gridAttentionTable").jqGrid({
                url: '${request.contextPath}/list!list.action',
                datatype: "json",
                mtype: "POST",
                colNames:['账单编号','处理编号','处理日期','处理说明','处理人','处理部门','备注','状态'],
                colModel:[
                {
                    name : 'billId',
                    jsonmap : 'BILL_ID',
                    index : 'BILL_ID',
                    hidden:false, 
                    editable : false,
                    searchoptions : {sopt : [ "eq", "cn"]}
                },{
                    name : 'billDtlId',
                    jsonmap : 'BILL_DTL_ID',
                    index : 'BILL_DTL_ID',
                    hidden:true, 
                    editable : false,
                    searchoptions : {sopt : [ "eq", "cn"]}
                },{
                    name : 'dealDate',
                    jsonmap : 'DEAL_DATE',
                    index : 'DEAL_DATE',
                    formatter : 'date',                
                    formatoptions : {srcformat : 'Y/m/d',newformat : 'Y-m-d'},
                },{
                    name: 'dealNote', 
                    jsonmap: 'DEAL_NOTE', 
                    index:'DEAL_NOTE', 
                    searchoptions : {sopt : [ "eq", "cn"]}
                },{
                    name : 'dealBy',
                    jsonmap : 'DEAL_BY',
                    index : 'DEAL_BY',
                    searchoptions : {sopt : [ "eq", "cn"]}   
                },{
                    name : 'dealDepartment',
                    jsonmap : 'DEAL_DEPARTMENT',
                    index : 'DEAL_DEPARTMENT',
                    searchoptions : {sopt : [ "eq", "cn"]}
                },{
                    name : 'remark',
                    jsonmap : 'REMARK',
                    index : 'REMARK',
                    searchoptions : {sopt : [ "eq", "cn"]}    
                },{
                    name: 'status', 
                    jsonmap: 'STATUS', 
                    index:'STATUS', 
                    hidden:true,
                    searchoptions : {sopt : [ "eq", "cn"]}
                }],
                sortname : 'BILL_DTL_ID',
                sortorder : 'desc',
                viewrecords : true,
                gridview : true,
                rownumbers : true,
                autowidth: true,
                multiselect : false,
                rowNum : 20,
                rowList : [10,20,30],
                jsonReader : {
                    page : "page.pageNo", //固定名称
                    total : "page.totalPages", //固定名称
                    records : "page.totalCount", //固定名称
                    root : "page.result", //固定名称
                    repeatitems : false, //固定
                    id : 'BILL_DTL_ID'
                },
                prmNames : {
                    rows : "page.pageSize",
                    page : "page.pageNo",
                    sort : "page.orderBy",
                    order : "page.order"
                },
                loadBeforeSend:function(xhr,settings){
                    //设置需要访问的list标签
                    settings.data = settings.data+ "&gridKey=/list#TsmBillDtl";
                    return true;
                },
                pager : "#gridAttentionPager"
            });
                jQuery("#gridAttentionTable").trigger('reloadGrid');
            },
            buttons : {
               "关闭":function() {$("#gridDialog").dialog("close")}
            }
    });
});

</#macro>

<#macro main>
        <table id="gridTable"></table>
        <div id="gridPager"></div>
        
        <div id="gridDialog">
            <form id="consoleForm">
                <input type="hidden" id="selectId" />
                <table id="gridAttentionTable" class="formTable">
                </table>
                <div id="gridAttentionPager"></div>
            </form>
        </div>
</#macro>